// RMQ Algorithms#include<stdio.h>int n,z = 1,tree[1001],R,L,ans,m,value1,value2,i;void RMQ (int R, int L);int main () {        scanf("%d",&n);    while (n > z) {        z *= 2;    }    for (i = z; i<=z+n-1 ; i++) {        scanf("%d", &tree[i]);    }    scanf("%d",&m);        for (i = z-1 ; i >= 1; i--) {        tree[i] = tree[2*i] + tree[2*i+1];    }    for (i = 0 ; i < m ; i++) {        scanf("%d %d", &value1 ,&value2);        RMQ(value1+z-1,value2+z-1);        printf("%d",ans);    }    }void RMQ (int L, int R) {        ans = 0 ;    while (L <= R){        if (L % 2 == 1) {            ans += tree[L];        }if (R % 2 == 0) {            ans += tree[R];        }        L = (L+1)/2;        R = (R-1)/2;    }    }